/*
 * @Author: [you name]
 * @Date: 2021-10-25 09:24:59
 * @LastEditors: [you name]
 * @LastEditTime: 2021-11-08 00:01:05
 * @Description: 
 */
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' },
      hidden: true
    }]
  },

  {
    path: '/category',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Category',
        component: () => import('@/views/category/index'),
        meta: { title: '栏目管理', icon: 'category' }
      }
    ]
  },
 
  {
    path: '/production',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Production',
        component: () => import('@/views/production/index'),
        meta: { title: '产品管理', icon: 'product' }
      }
    ]
  },

  {
    path: '/customer',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Customer',
        component: () => import('@/views/customer/index'),
        meta: { title: '顾客管理', icon: 'customer' }
      },
      {
        path: 'details',
        name: 'CustomerDetails',
        component: () => import('@/views/customer/details'),
        hidden: true 
      }
    ]
  },

  {
    path: '/employee',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Employee',
        component: () => import('@/views/employee/index'),
        meta: { title: '员工管理', icon: 'employee' }
      },
      {
        path: 'details',
        name: 'EmployeeDetails',
        component: () => import('@/views/employee/details'),
        hidden: true 
      }
    ]
  },

  {
    path: '/order',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Order',
        component: () => import('@/views/order/index'),
        meta: { title: '订单管理', icon: 'order' }
      
      },
      {
        path: 'details',
        name: 'OrderDetails',
        component: () => import('@/views/order/details'),
        hidden: true 
      }
    ]
  },

  {
    path: '/check',
    component: Layout,
    // 路由从定向
    // redirect: '/check',
    name: 'Check',
    meta: { title: '账单管理', icon: 'check' },
    children: [
      {
        path: 'cusome',
        name: 'Custome',
        component: () => import('@/views/check/custome'),
        meta: { title: '顾客账单' },
            
      },
      {
        path: 'employee',
        name: 'Employee',
        component: () => import('@/views/check/employee'),
        meta: { title: '员工账单' },
            
      },
      {
        path: 'system',
        name: 'System',
        component: () => import('@/views/check/system'),
        meta: { title: '系统账单' },
            
      }

    ]
  },
  
  {
    path: '/auditing',
    component: Layout,
    // 路由从定向
    // redirect: '/check',
    name: 'Auditing',
    meta: { title: '审核管理', icon: 'auditing' },
    children: [
      {
        path: 'attestation',
        name: 'Attestation',
        component: () => import('@/views/auditing/attestation'),
        meta: { title: '实名认证' },
            
      },
      {
        path: 'modify',
        name: 'Modify',
        component: () => import('@/views/auditing/modify'),
        meta: { title: '账户变更' },
            
      },
      {
        path: 'order',
        name: 'Order',
        component: () => import('@/views/auditing/order'),
        meta: { title: '订单评论' },
            
      },
      {
        path: 'imformation',
        name: 'Imformation',
        component: () => import('@/views/auditing/imformation'),
        meta: { title: '资讯评论' },
            
      }

    ]
  },

  {
    path: '/info',
    component: Layout,
    // 路由从定向
    // redirect: '/check',
    name: 'Info',
    meta: { title: '网站资讯', icon: 'info' },
    children: [
      {
        path: 'category',
        name: 'Category',
        component: () => import('@/views/info/category'),
        meta: { title: '资讯分类' },
            
      },
      {
        path: 'article',
        name: 'Article',
        component: () => import('@/views/info/article'),
        meta: { title: '资讯信息' },
            
      },
      
    ]
  },

 

  {
    path: '/basconfig',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Basconfig',
        component: () => import('@/views/basconfig/index'),
        meta: { title: '系统设置', icon: 'basconfig' }
      }
    ]
  },
 
  {
    path: '/carousel',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Carousel',
        component: () => import('@/views/carousel/index'),
        meta: { title: '轮播图管理', icon: 'carousel' }
      }
    ]
  },

  {
    path: '/log',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'log',
        component: () => import('@/views/log/index'),
        meta: { title: '日志管理', icon: 'log' }
      }
    ]
  },
 
  {
    path: '/owner',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Owner',
        component: () => import('@/views/owner/index'),
        meta: { title: '个人信息', icon: 'owner' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
